#include<iostream>
#include<cstring>
using namespace std;
const int N = 1e3 + 10;
void Get_Next(char str2[], int next[])
{
	int i = 0;
	int j = -1;
	next[0] = -1;
	int len2 = strlen(str2);
	while (i < len2) {
		if ( str2[i] == str2[j] || j == -1) {
			i++;
			j++;
			if (str2[i] == str2[j]) {
				next[j] = j;
			}
			else {
				next[j] = i;
			}
		}
		else {
			j = next[j];
		}
	}
}
int main()
{
	int next[N];
	char str1[100];
	char str2[100];
	int i = 0;
	int j = 0;
	cin >> str1 >> str2;
	Get_Next(str2, next);
	while (i < strlen(str1) && j < strlen(str2))
	{
		if (str1[i] == str2[j]||j==-1) {
			i++;
			j++;
		}
		else {
			j = next[j];
		}
	}
	if (j == strlen(str2)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}